*********************************************************
*********************************************************  
*** GBR 2024 --- JPE Revision Package *******************
*** Code to prepare the dataset of Study 1 **************
*** Public (anonymized) *********************************
*********************************************************

** Note: this code is use for cleaning the dataset for Study 1 for it being
* used together with the datasets of Studies 2 and 3. It has been already 
* pre-cleaned before, including for anonymization.

clear all
use ".../JPEReplicationPackageDataverse/GBR24DataStudy1.dta"

set more off
destring, replace

** Drop workers who did not complete Study 1 within the 65-min. time limit
* and the associated variables (the other studies end automatically at their
* time limit and worker's labor supply is recorded then, so they do 
* not need this step in the code)
drop if overtimelimit_study1==1
drop overtimelimit_study1 SC0

** Create control variables
* Age categories (age variable from Prolific)
gen age60=0  if age!=.
replace age60=1 if age>=60 & age!=.
gen age50=0 if age!=.
replace age50=1 if age>=50 & age<60
gen age40=0  if age!=.
replace age40=1 if age>=40 & age<50
label variable age40 "Age 40-49 indicator: 0No 1Yes"
label variable age50 "Age 50-59 indicator: 0No 1Yes"
label variable age60 "Age 60+ indicator: 0No 1Yes"

* Ethnicity: white vs. non-white indicator
gen white=0 if ethnicity!=""
replace white=1 if ethnicity=="Caucasian"
label variable white "White (vs. non-white) indicator: 0No 1Yes"

* Re-code and re-scale questionnaire questions post experiment, common Studies 1--3
* PE1, understand instructions
replace PE1="1" if PE1=="(Not at all) 1 "
replace PE1="7" if PE1=="(Very well) 7 "
destring PE1, replace
gen PE1_UnderstandInst=PE1-1
label variable PE1_UnderstandInst "Common: Understood instructions scale: 0 (not at all) to 6 (very well)"
* PE3, trust instructions
replace PE3="1" if PE3=="(Not at all) 1 "
replace PE3="7" if PE3=="(Completely) 7 "
destring PE3, replace
gen PE3_TrustInst=PE3-1
label variable PE3_TrustInst "Common: Trusted instructions scale: 0 (not at all) to 6 (completely)"
* PE4, discussed study before participating
replace PE4="1" if PE4=="No"
replace PE4="2" if PE4=="Yes"
destring PE4, replace
gen PE4_DiscussSomeoneElse=PE4-1
label variable PE4_DiscussSomeoneElse "Common: Discussed study with other Prolific user who participated before study: 0No 1Yes"
* PE5, helped by someone else
replace PE5="1" if PE5=="No"
replace PE5="2" if PE5=="Yes"
destring PE5, replace
gen PE5_HelpSomeoneElse=PE5-1
label variable PE5_HelpSomeoneElse "Common: Completed this study with the help of someone else: 0No 1Yes"
* PE6, participated in similar experiment before
replace PE6="1" if PE6=="No"
replace PE6="2" if PE6=="Yes"
destring PE6, replace
gen PE6_ParticipatedSimilarExp=PE6-1
label variable PE6_ParticipatedSimilarExp "Common: Participated in similar experiment before: 0No 1Yes"

* Create indicator for UK nationality
gen nat_uk=0 if nationality!="United Kingdom" & nationality!=""
replace nat_uk=1 if nationality=="United Kingdom" 
label variable nat_uk "Nationality indicator: 0Non-UK 1UK"

* Create indicator for students
gen student=0 if student_status=="No"
replace student=1 if student_status=="Yes"
label variable student "Student indicator: 0No 1Yes"

* Create employment status indicators
gen employed=.
replace employed=1 if employment_status=="Full-Time"
replace employed=0 if employment_status=="Not in paid work (e.g. homemaker, retired or disabled)"
replace employed=0 if employment_status=="Other"
replace employed=0 if employment_status=="Part-Time"
replace employed=0 if employment_status=="Unemployed (and job seeking)"
label variable employed "E: Employed full time indicator: 0No 1Yes"

gen unemployed=.
replace unemployed=0 if employment_status=="Full-Time"
replace unemployed=0 if employment_status=="Not in paid work (e.g. homemaker, retired or disabled)"
replace unemployed=0 if employment_status=="Other"
replace unemployed=0 if employment_status=="Part-Time"
replace unemployed=1 if employment_status=="Unemployed (and job seeking)"
label variable unemployed "E: Unemployed indicator: 0No 1Yes"

gen parttime=.
replace parttime=0 if employment_status=="Full-Time"
replace parttime=0 if employment_status=="Not in paid work (e.g. homemaker, retired or disabled)"
replace parttime=0 if employment_status=="Other"
replace parttime=1 if employment_status=="Part-Time"
replace parttime=0 if employment_status=="Unemployed (and job seeking)"
label variable parttime "E: Employed part time indicator: 0No 1Yes"

gen notInPaidJob=.
replace notInPaidJob=0 if employment_status=="Full-Time"
replace notInPaidJob=1 if employment_status=="Not in paid work (e.g. homemaker, retired or disabled)"
replace notInPaidJob=0 if employment_status=="Other"
replace notInPaidJob=0 if employment_status=="Part-Time"
replace notInPaidJob=0 if employment_status=="Unemployed (and job seeking)"
label variable notInPaidJob "E: Not in paid job indicator: 0No 1Yes"

gen otheremployment=.
replace otheremployment=0 if employment_status=="Full-Time"
replace otheremployment=0 if employment_status=="Not in paid work (e.g. homemaker, retired or disabled)"
replace otheremployment=1 if employment_status=="Other"
replace otheremployment=0 if employment_status=="Part-Time"
replace otheremployment=0 if employment_status=="Unemployed (and job seeking)"
label variable otheremployment "E: Other employement status indicator: 0No 1Yes"


** Create variable to identify each study, and ID variable (1,000,000 range 
* denotes IDs in Study 1)
gen study=1
gen id=1000000 + _n
label variable study "Study: 1Study1 2Study2 3Study3 4Study4 5Study5 6Study6"
label variable id "Worker ID: 1,000,000 range for Study 1, 2,000,000 for Study 2,..."

** Create alternative wage variable
gen w=3 if low_wage==1
replace w=6 if high_wage==1
label variable w "Piece-rate wage in approx. 2018 equivalent: 3(low-wage) 6(high-wage)"

** Create inequality aversion variables (for parameter estimation in Appendix)
gen dis_ineq=0 
replace dis_ineq=6-3 if low_unequal==1
label variable dis_ineq "Disadvantageous piece-rate wage inequality"
gen adv_ineq=0
replace adv_ineq=6-3 if high_unequal==1
label variable adv_ineq "Advantageous piece-rate wage inequality"
gen d_dis_ineq=0 
replace d_dis_ineq=6-3 if low_disc==1
label variable d_dis_ineq "Gender-disc disadvantageous piece-rate wage inequality"
gen d_adv_ineq=0
replace d_adv_ineq=6-3 if high_disc==1
label variable d_adv_ineq "Gender-disc advantageous piece-rate wage inequality"

* Standardize labor supply based on unequal low wage scheme (mean 38.32704, sd 28.21157)
sum l if low_unequal==1 & study==1
gen sd_l=(l-38.32704)/28.21157 if study==1
label variable sd_l "Standardized labor supply (based on UnEq low-wage workers)"

* Standardize labor supply by gender based on unequal low wage scheme of each gender (men: mean 34.625, sd 27.71934; women: mean 42.07595, sd 28.29723)
sum l if low_unequal==1 & study==1 & woman==0
sum l if low_unequal==1 & study==1 & woman==1
gen sd_l_gender=(l-34.625)/27.71934 if study==1 & woman==0
replace sd_l_gender=(l-42.07595)/28.29723 if study==1 & woman==1
label variable sd_l_gender "Gender-standardized labor supply (based on UnEq low-wage workers of each gender)"

** Adapt comprehension question to format of Studies 2 and 3
tab C2
replace C2="1" if C2=="Identify locations on pictures"
replace C2="2" if C2=="Solve puzzles"
replace C2="3" if C2=="Enter sequences of random numbers and/or letters"
replace C2="4" if C2=="Complete a general knowledge quizz"
label variable C2  "1st ans. to compr. quest. on what the task is, correct:3"

tab C4
replace C4="1" if C4=="No, the lines that I enter have some further uses for other participants"
replace C4="2" if C4=="No, the lines that I enter have some further uses for the researchers"
replace C4="3" if C4=="Maybe"
replace C4="4" if C4=="Yes, the lines that I enter have no further use for anyone"
label variable C4 "1st ans. to compr. quest. on whether task has further uses for anyone, correct:4"

tab C9
replace C9="1" if C9=="I receive £0.60 regardless of what I do"
replace C9="2" if C9=="I receive £1.00 regardless of what I do"
replace C9="3" if C9=="I receive £0.70 plus a payment per line entered"
replace C9="4" if C9=="I simply receive a payment per line entered"
replace C9="5" if C9=="I do not receive a monetary payment, regardless of what I do"
label variable C9 "1st ans. to compr. quest. on how we pay workers, correct:3"
destring C2 C4 C9, replace

** Save dataset
save ".../JPEReplicationPackageDataverse/GBR24DataCleanStudy1.dta", replace
